<template>
  <div class="under-development">
    <div class="content">
      <div class="icon-container">
        <coffee-outlined class="icon" />
      </div>
      <h1 class="title">哎呀，被你发现了！</h1>
      <p class="description">这个功能目前正在"烹饪"中，站长正在熬夜加班，一边喝咖啡一边敲代码...</p>
      <div class="progress-container">
        <a-progress :percent="42" status="active" />
        <p class="progress-text">开发进度：42%（站长说这是生命、宇宙以及任何事情的终极答案）</p>
      </div>
      <div class="message">
        <p>站长正在：</p>
        <a-typography-text code>
          <span class="typing">{{ currentText }}<span class="cursor">|</span></span>
        </a-typography-text>
      </div>
      <div class="excuses">
        <a-collapse>
          <a-collapse-panel key="1" header="站长的借口合集 (点击展开)">
            <a-timeline>
              <a-timeline-item>昨晚调试到凌晨三点，结果发现是少了个分号</a-timeline-item>
              <a-timeline-item>代码刚写完，猫走过键盘，全没了</a-timeline-item>
              <a-timeline-item>正在研究量子计算来优化加载速度</a-timeline-item>
              <a-timeline-item>服务器说它需要休假</a-timeline-item>
              <a-timeline-item>代码写到一半，突然忘记自己在写什么</a-timeline-item>
            </a-timeline>
          </a-collapse-panel>
        </a-collapse>
      </div>
      <a-button type="primary" size="large" @click="goBack" class="back-button">
        先去别处逛逛
      </a-button>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted, onUnmounted } from 'vue'
import { useRouter } from 'vue-router'
import { CoffeeOutlined } from '@ant-design/icons-vue'

const router = useRouter()

const texts = [
  '修复了99个bug，又引入了100个新bug',
  'npm install coffee-to-code-converter',
  'git commit -m "这次一定能用了"',
  'stackoverflow.com/how-to-fix-everything',
  'while(true) { tryToFixBugs(); }',
  'console.log("为什么不工作？？？")',
]

const currentText = ref('')
let currentIndex = 0
let charIndex = 0
let typingInterval: number | null = null
let pauseTimeout: number | null = null

const typeText = () => {
  if (charIndex < texts[currentIndex].length) {
    currentText.value = texts[currentIndex].substring(0, charIndex + 1)
    charIndex++
  } else {
    // 完成当前文本的打字，暂停一会儿
    if (pauseTimeout) clearTimeout(pauseTimeout)
    pauseTimeout = setTimeout(() => {
      charIndex = 0
      currentIndex = (currentIndex + 1) % texts.length
    }, 2000) as unknown as number
  }
}

const goBack = () => {
  console.log('goBack')
  router.push('/')
}

onMounted(() => {
  typingInterval = setInterval(typeText, 100) as unknown as number
})

onUnmounted(() => {
  if (typingInterval) clearInterval(typingInterval)
  if (pauseTimeout) clearTimeout(pauseTimeout)
})
</script>

<style scoped>
.under-development {
  min-height: 100vh;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  padding: 20px;
  position: fixed;
  top: 0;
  left: 0;
  overflow-y: auto;
}

.content {
  max-width: 800px;
  width: 90%;
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  padding: 40px;
  text-align: center;
  margin: auto;
}

.icon-container {
  margin-bottom: 20px;
}

.icon {
  font-size: 60px;
  color: #1890ff;
}

.title {
  font-size: 36px;
  font-weight: bold;
  margin-bottom: 16px;
  color: #1890ff;
}

.description {
  font-size: 18px;
  color: #666;
  margin-bottom: 30px;
}

.progress-container {
  margin: 30px 0;
}

.progress-text {
  margin-top: 10px;
  font-size: 14px;
  color: #888;
  font-style: italic;
}

.message {
  margin: 30px 0;
  background-color: #f5f5f5;
  padding: 20px;
  border-radius: 8px;
}

.typing {
  font-family: monospace;
  font-size: 16px;
}

.cursor {
  animation: blink 1s infinite;
}

.excuses {
  margin: 30px 0;
}

.back-button {
  margin-top: 30px;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

@media (max-width: 768px) {
  .content {
    padding: 20px;
    margin: 20px;
    width: calc(100% - 40px);
  }

  .title {
    font-size: 28px;
  }

  .description {
    font-size: 16px;
  }
}
</style> 